<?php
/**
  * Musashi - A project manager for music groups and bands
  * Copyright (C) 2010 Daniel Torres
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  */

/**
 * Administrates user maintenance operations
 *
 * @package Musashi
 * @author Daniel Torres
 */
 
// Make sure we have access to this page
defined('_JEXEC') or die ('Restricted access. Sorry');

class MusashiControllerUser extends JController
{
    /**
     *  Constructor
     */
    function __construct()
    {
        parent::__construct();
        
        // Register the ADD as part of the EDIT
        $this->registerTask('add','edit');
    }
    
    /**
     *  Makes sure this operation is valid by checking the validFormCheck flag.
     *  The flag is automatically reset upon call.
     */
    function isValidForm()
    {
        $session =& JFactory::getSession();
        $result = $session->get('validFormCheck',false);
        $session->set('validFormCheck',false);
        
        return $result;
    }
    
    /**
     *  Adds a new user into the DB
     */
    function update()
    {
        // Make sure this is a valid form
        if( $this->isValidForm() )
        {
            $model = $this->getModel('user');
            
            if( $model->updateUserData() )
            {
                // Redirect to the place we were originally going to
                $session =& JFactory::getSession();
                $session->set('actionResult','Information updated!');                
                $this->setRedirect($session->get('musashiRedirect','index.php'));
            }
            
        }
    }
    
    
    /**
     *  Displays the required content
     */
    function display()
    {
        parent::display();
    }

}

?>